
//
//  HotelDetailVController.m
//  Travel assistant
//
//  Created by lanou3g on 16/3/12.
//  Copyright © 2016年 旅游助手. All rights reserved.
//

#import "HotelDetailVController.h"

@interface HotelDetailVController ()
@property (nonatomic, strong) HotelDetalModel *hotelDetalModel;

@end

@implementation HotelDetailVController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setViews];
    
}
- (void)setViews{
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"correct_31.883720930233px_1163714_easyicon.net"] style:UIBarButtonItemStyleDone target:self action:@selector(rightBarButtonItemAction:)];
    
    
    
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self.hotelImV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://api.map.baidu.com/panorama?width=512&height=256&location=%f,%f&fov=180&ak=iHGsgUK7quL7Qi3yhdMk095S",self.passHotelModel.pt.longitude, self.passHotelModel.pt.latitude]] completed:nil];
    self.nameLable.text = self.passHotelModel.name;
    self.addressLable.text = self.passHotelModel.address;
    self.telLable.text = self.passHotelModel.phone;
    
}
- (void)rightBarButtonItemAction:(UIBarButtonItem *)sender{
    self.hotelDetalModel = [HotelDetalModel object];
    NSData *imageData = UIImagePNGRepresentation(self.hotelImV.image);
    AVFile *imageFile = [AVFile fileWithData:imageData];
    [self.hotelDetalModel setObject:imageFile forKey:@"hotelImage"];
    [self.hotelDetalModel setObject:self.passHotelModel.name forKey:@"hotelName"];
    [self.hotelDetalModel setObject:self.passHotelModel.address forKey:@"hotelAddress"];
    [self.hotelDetalModel setObject:self.passHotelModel.phone forKey:@"hotelTel"];
    
    [self.hotelDetalModel saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (succeeded) {
            NSLog(@"self.hotelDetalModel保存成功......");
        } else {
            NSLog(@"%@",error);
        }
    }];
    [self.navigationController popToRootViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
